// 引入
const express = require('express')

// 创建应用对象
var app = express()

// 配置静态资源
// public是文件名,通常是用public
app.use(express.static('public'))

const allUsers = [{id:1,name:'a',age:14},{id:2,name:'b',age:16},{id:3,name:'c',age:20}]

app.get('/user/:id',(req,res)=>{
    // const {id} = req.params
    // let auser = allUsers.find(user=> user.id ==id)
    // res.send(auser)

    let {user} = req.query
    console.log(req.query);
    console.log(user);
    let flag = allUsers.some(item=>item.name === user)
    console.log(flag);
    if(flag){
        res.send('登录成功')
    }
    // let auser = allUsers.find(user=> user.id ==id)
    // res.send(auser)
})


// 启动服务,监听9898端口
app.listen('9898',()=>{
    console.log('启动成功:localhost:9898');
})